package com.inspur.security.cbb3.kms.keyusage.data.controller;

import com.inspur.security.cbb3.kms.annotation.SysLog;
import com.inspur.security.cbb3.kms.enums.BusinessType;
import com.inspur.security.cbb3.kms.enums.SystemCode;
import com.inspur.security.cbb3.kms.keyusage.data.po.DataBean;
import com.inspur.security.cbb3.kms.keyusage.data.service.DataService;
import com.inspur.security.cbb3.kms.utils.ResultUtil;
import javassist.NotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.*;

/**
 * DataController
 *
 * @author liukai
 * @date 2020/10/20
 **/
@RestController
@RequestMapping("/v1/data")
public class DataController {

    @Autowired
    private DataService dataService;

    @GetMapping("/{uuid}/resultdata")
    @SysLog(title = "数据下载", businessType = BusinessType.EXPORT)
    public ResponseEntity downData(@PathVariable(name = "uuid") String uuid) throws MissingServletRequestParameterException,  NotFoundException {
        DataBean bean = dataService.downData(uuid);
        return ResultUtil.dataReturn(SystemCode.SUCCESS, bean, HttpStatus.OK);
    }

//    @DeleteMapping
//    public ResponseEntity deleteData(@PathVariable(name = "uuid") String uuid) throws MissingServletRequestParameterException,  NotFoundException {
//        dataService.deleteData(uuid);
//        return ResultUtil.noDataReturn(SystemCode.SUCCESS, HttpStatus.OK);
//    }

}
